<template>
	<el-dialog :title="`《`+this.folderName+`》共享设置`" v-model="visible" :width="600" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="共享权限">
				<select-user-dialog v-model:accountId="form.shareRole" :mode="true"/>
			</el-form-item>
			<el-form-item label="编辑权限">
				<select-user-dialog v-model:accountId="form.editRole" :mode="true"/>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">设 置</el-button>
		</template>
	</el-dialog>
</template>
<script>
import selectUserDialog from "@/views/module/selectUserDialog";
export default {
	emits: ['success', 'closed'],
	components: {
		selectUserDialog,
	},
	data() {
		return {
			components: {
				selectUserDialog
			},
			folderName: "",
			form: {
				folderId:"",
				shareRole:"",
				editRole:""
			},
			rules: {},
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {

	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this;
		},
		//表单提交方法
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.file.personalFile.updatePersonalFileFolder.post(this.form);
					this.isSaveing = false;
					if (res.code == 200) {
						this.visible = false;
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		//表单注入数据
		setData(data) {
			this.form.folderId = data.fileId;
			this.folderName = data.fileName;
			this.form.shareRole = data.shareRole;
			this.form.editRole = data.editRole;
		}
	}
}
</script>

<style>
</style>
